package framework.service.impl;

import framework.bo.SysUserRole;
import framework.dao.ISysUserRoleDao;
import framework.service.SysUserRoleService;
import framework.util.controller.BaseController;
import framework.util.layui._LayuiUtil;
import framework.util.queryFilter.service.impl.IBaseServiceImpl;
import javax.annotation.Resource;

import framework.util.queryFilter.service.impl.QueryFilter;
import framework.util.queryFilter.vo.Where;
import framework.util.shiro._ShiroUtil;
import framework.vo.SysRoleVo;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service("SysUserRoleService")
public class SysUserRoleServiceImpl extends IBaseServiceImpl<SysUserRole, Integer> implements SysUserRoleService {

    @Resource
    private ISysUserRoleDao dao;

    //TODO sysUser的isDelete为null
    @Override
    public List<Integer> getSysRoleLidsByCurrentUser() {
        List<SysUserRole> sysUserRoleList = dao.getRoleLidsByCurrentUser(BaseController.getCurrentUser().getLid());
        List<Integer> roleLids = sysUserRoleList.stream().map(item -> item.getRoleLid()).collect(Collectors.toList());
        return roleLids;
    }

    @Override
    public List<SysRoleVo> getSysRoleVoByUserLid(Integer SysUserLid) {
        List<SysRoleVo> list = dao.getSysRoleVoByCurrentUser(SysUserLid);
        return list;
    }
}

